package de.jmda.core.util.fileset;

import java.io.File;
import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import de.jmda.core.util.fileset.FileSet.RuleSetUpdateMode;

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class FileSetJavaFilesOnly
{
	@XmlElement
	private FileSet fileSet = new FileSet();
	
	@XmlElement
	private FileFilterJavaSourceFilesOnly fileFilter =
			new FileFilterJavaSourceFilesOnly();

	public void includeDirectory(
			File directory, RuleSetUpdateMode ruleSetUpdateMode)
	{
		fileSet.includeDirectory(directory, fileFilter, ruleSetUpdateMode);
	}
	
	public void includeDirectoryRecursive(
			File directory, RuleSetUpdateMode ruleSetUpdateMode)
	{
		fileSet.includeDirectoryRecursive(directory, fileFilter, ruleSetUpdateMode);
	}
	
	public void includeFile(File file, RuleSetUpdateMode ruleSetUpdateMode)
	{
		if (fileFilter.accept(file))
		{
			fileSet.includeFile(file, ruleSetUpdateMode);
		}
	}
	
	public void excludeDirectory(
			File directory, RuleSetUpdateMode ruleSetUpdateMode)
	{
		fileSet.excludeDirectory(directory, fileFilter, ruleSetUpdateMode);
	}
	
	public void excludeDirectoryRecursive(
			File directory, RuleSetUpdateMode ruleSetUpdateMode)
	{
		fileSet.excludeDirectoryRecursive(directory, fileFilter, ruleSetUpdateMode);
	}
	
	public void excludeFile(File file, RuleSetUpdateMode ruleSetUpdateMode)
	{
		if (fileFilter.accept(file))
		{
			fileSet.excludeFile(file, ruleSetUpdateMode);
		}
	}
	
	public Set<File> getIncludeDirectories()
	{
		return fileSet.getIncludeDirectoryRules();
	}
	
	public Set<File> getIncludeDirectoriesRecursive()
	{
		return fileSet.getIncludeDirectoryRecursiveRules();
	}
	
	public Set<DirectoryFileFilter> getIncludeDirectoryFilters()
	{
		return fileSet.getIncludeDirectoryFilterRules();
	}
	
	public Set<DirectoryFileFilter> getIncludeDirectoryFiltersRecursive()
	{
		return fileSet.getIncludeDirectoryFilterRecursiveRules();
	}
	
	public Set<File> getIncludeFiles()
	{
		return fileSet.getIncludeFileRules();
	}
	
	public Set<File> getExcludeDirectories()
	{
		return fileSet.getExcludeDirectoryRules();
	}
	
	public Set<File> getExcludeDirectoriesRecursive()
	{
		return fileSet.getExcludeDirectoryRecursiveRules();
	}
	
	public Set<DirectoryFileFilter> getExcludeDirectoryFilters()
	{
		return fileSet.getExcludeDirectoryFilterRules();
	}
	
	public Set<DirectoryFileFilter> getExcludeDirectoryFiltersRecursive()
	{
		return fileSet.getExcludeDirectoryFilterRecursiveRules();
	}
	
	public Set<File> getExcludeFiles()
	{
		return fileSet.getExcludeFileRules();
	}
	
	public Set<File> calculateFileSet()
	{
		return fileSet.calculateFileSet();
	}
}